<?php
	//var_dump($_POST);
	$pageSize=$_POST['pageSize'];
	$page=$_POST['curPage'];
	if (!isset($page)) {
		$page=1;
	}
	$startCount=($page-1)*$pageSize;
	//连接数据库

	$con=new mysqli("localhost","root","123456","myDB");
	$con->query("set names utf8");
	//读取数据
	$count=$con->query("SELECT count(*) as count FROM users");
	$rw=$count->fetch_assoc();

	$sql="SELECT * FROM users ORDER BY registerTime DESC LIMIT $startCount,$pageSize";

	$result=$con->query($sql);
	if($result->num_rows>0){
		$users=array();
		$i=0;
		while($row=$result->fetch_assoc()){
			$users[$i]=$row;
			$i++;
		}
		echo json_encode(array("success"=>true,"totalRows"=>$rw['count'],"curPage"=>$page, 'data'=>$users));
	}else{
		echo json_encode(array("success"=>true,"totalRows"=>0,"curPage"=>1, 'data'=>[]));;
	}
	$con->close();
?>